﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using School.Entities;

namespace School.Common
{
    
   public static class fn_privilage
    {

       public static SchoolEntities db = new SchoolEntities();
   
       public  static IQueryable GetUserInfo()
      {
      var username = from u in db.ORG_Stuff
                     select new { name = u.FName +""+u.LName, id = u.Id };
      return username;
       }

       public static IQueryable GetAllPrivilege()
       {
           var get = from g in db.SEC_ScreenCode
                     select new { pagename = g.ScreenName, Id = g.Id };
           return get;
       }
    
  // geting user pages code 
       public static IQueryable<int> getpagecodeID(int id )
       {
           var get = from g in db.SEC_UesersPrivilages
                   
                     where g.UserId == id
                     select g.ScreenCodeId;
           return get;
       }
       public static IQueryable<int> getpagecode(int id)
       {
           var get = from g in db.SEC_UesersPrivilages
                     where g.UserId == id 
                     join j in db.SEC_ScreenCode
                     on g.ScreenCodeId equals j.Id into code
                     from ggg in code
                     
                     select ggg.ScreenCode;
                    
           return get;
       }
     public static IQueryable<int> GetUserPrivlage(ORG_Stuff c)
       {
           var privlage = from p in db.SEC_UesersPrivilages
                           where p.Id == c.Id
                           select p.ScreenCodeId;
           return privlage;
       }
   }
        
    }
